package ext.opensource.netty.common.core;

import java.util.concurrent.ConcurrentHashMap;

public class CacheListLocalMemory<V> extends BaseCacheList<V> {
	private final ConcurrentHashMap<String, V> msgList = new ConcurrentHashMap<String, V>();

	@Override
	public boolean put(final String key, final V value) {
		return msgList.put(key, value) == null;
	}

	@Override
	public V get(final String key) {
		if (key == null) {
			return null;
		} else {
			return msgList.getOrDefault(key, null);
		}
	}

	@Override
	public V remove(final String key) {
		return msgList.remove(key);
	}

	@Override
	public long size() {
		return msgList.size();
	}

	@Override
	public boolean exists(final String key) {
		return msgList.containsKey(key);
	}
}
